package com.jt.rabbitmq.work;

import com.jt.utils.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class WorkTest {
    private static final String QUEUE_NAME = "workThread——test";

    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionUtil ConnectionUtil = new ConnectionUtil();
        Connection connection = ConnectionUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUE_NAME, true, false, false, null);

        for (int i = 0; i < 10; i++) {
            String message = i+"work模式测试";
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
        }
        System.out.println("消息发送完毕。。即将关闭");
        channel.close();
    }
}
